import axios from '~/plugins/axios';

import * as types from '../../mutation-types/report/index';

/**
 * 新增客户统计列表
 *
 * @param commit
 * @param state
 * @param preload
 */

export const getAddData = function ({commit, state}, preload) {
    return axios.get(process.env.baseUrl + '/customer/statisticslist',{
      params : {
        startDate:preload.startDate,
        endDate:preload.endDate,
        customerlevel: preload.customerlevel,
        deptId: preload.deptId,
        usId: preload.usId
      }
    });
};

/**
 * 客户所有者统计
 *
 * @param commit
 * @param state
 * @param preload
 */

export const getOwnerList = function ({commit, state}, preload) {
    return axios.get(process.env.baseUrl + '/customer/ownerlist', {
      params : {
        //startDate:preload.startDate,
        //endDate:preload.endDate,
        date:preload.startDate,
        //customerlevel: preload.customerlevel,
        deptId: preload.deptId,
        usId: preload.usId
      }
  })
};


/**
 * 库容量统计
 *
 * @param commit
 * @param state
 * @param preload
 */

export const getCapacityData = function ({commit, state}, preload) {
    return axios.post(process.env.baseUrl + '/report/cusLevelDistributeByDpt', {
      params : {
        startDate:preload.startDate,
        endDate:preload.endDate,
        customerlevel: preload.customerlevel,
        deptId: preload.deptId,
        usId: preload.usId
      }
  })
        
};

/**
 * 联系量统计-部门统计
 *
 * @param commit
 * @param state
 * @param preload
 */

export const getFollowList = function ({commit, state}, preload) {
    let url = (preload.startDate === preload.endDate)?
            '/follow/listFollowEveryHours'
            :'/follow/listFollowByDate';
    return axios.get(process.env.baseUrl + url, {
      params : {
        startTime:preload.startDate,
        endTime:preload.endDate,
        levels: preload.customerlevel,
        contactState: preload.contactState,
        deptId:preload.deptId,
        userIds:preload.usId,
        //id: preload.deptId || preload.usId,
        flag: preload.flag
      }
  })
};


/**
 * 客户去向统计-
 *
 * @param commit
 * @param state
 * @param preload
 */

export const getDestinationList = function ({commit, state}, preload) {
    return axios.get(process.env.baseUrl + '/customer/golist', {
      params : {
        startDate:preload.startDate,
        endDate:preload.endDate,
        customerlevel:preload.customerlevel,
        deptId : preload.deptId,
        usId : preload.usId,
      }
  })
};


/**
 * 在线统计-
 *
 * @param commit
 * @param state
 * @param preload
 */

export const getOnlineList = function ({commit, state}, preload) {
    return axios.get(process.env.baseUrl + '/recorddetail/onLine', {
      params : {
        startDate:preload.startDate,
        endDate:preload.endDate,
        flag: preload.flag,
        id: preload.deptId || preload.usId,
        childId:preload.childId
      }
  })
};